//package com.translate.web.api.conf;
//
//import java.util.List;
//import java.util.Map;
//import java.util.concurrent.ConcurrentHashMap;
//
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.security.access.ConfigAttribute;
//import org.springframework.security.access.SecurityConfig;
//import org.springframework.security.core.userdetails.UserDetailsService;
//
//import com.translate.security.service.UmsResourceService;
//import com.translate.web.component.DynamicSecurityService;
//import com.translate.entity.UmsResource;
//import com.translate.web.security.logic.IUserDetailLogic;
//
//@Configuration
//public class CrmSecurityConfig {
//
//    private IUserDetailLogic logic;
//    
//    
//    @Autowired
//    private UmsResourceService resourceService;
//
//	@Bean
//    public DynamicSecurityService dynamicSecurityService() {
//        return new DynamicSecurityService() {
//            @Override
//            public Map<String, ConfigAttribute> loadDataSource() {
//                Map<String, ConfigAttribute> map = new ConcurrentHashMap<>();
//                List<UmsResource> resourceList = resourceService.listAll();
//                for (UmsResource resource : resourceList) {
//                    map.put(resource.getUrl(), new SecurityConfig(resource.getId() + ":" + resource.getName()));
//                }
//                return map;
//            }
//        };
//    }
//
//    @Autowired
//    public void setLogic(IUserDetailLogic logic) {
//		this.logic = logic;
//	}
//
//    @Bean
//    public UserDetailsService userDetailsService() {
//        //获取登录用户信息
//        return username -> logic.getUserDetails(username);
//    }
//	
//}


